/*
 * Copyright (c) 2016, www.zm0618.com All Rights Reserved..
 */

package com.ibetter.mr.parse.comment;

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhaojun on 2016/12/10.
 */
public class UserCommentReducer  extends Reducer<LongWritable,LongWritable,LongWritable,Text> {
    @Override
    protected void reduce(LongWritable key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {
        List<String> infoIdList=new ArrayList<String>();
        for (LongWritable value : values) {
            infoIdList.add(value.toString());
        }
        if (infoIdList.size()>0){
            context.write(key,new Text(StringUtils.join(infoIdList,",")));
        }
    }
}
